#pragma once
#include <iostream>
#define app Application::getInstance()

class GLFWwindow;
using ResizeCallback = void(*)(int width, int height);
using KeyBoardCallback = void(*)(int key, int action, int mods);

class Application {
public:
	~Application();
	static Application* getInstance();
	bool init(const int& width = 800, const int& height = 600);
	bool update();
	bool destroy();
	void setResizeCallback(ResizeCallback resizeCallback) { this->resizeCallback = resizeCallback; };
	void setKeyBoardCallback(KeyBoardCallback keyBoardCallback) { this->keyBoardCallback = keyBoardCallback; };
	int getWidth()const {
		return this->width;
	}
	int getHeight()const {
		return this->height;
	}
private:
	static Application* instance;
	int width{ 0 };
	int height{ 0 };
	GLFWwindow* window{ nullptr };
	ResizeCallback resizeCallback{ nullptr };
	KeyBoardCallback keyBoardCallback{ nullptr };
	Application();

private:
	static void frameBufferSizeCallback(GLFWwindow* window, int width, int height);
	static void keyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
};